package com.tuni.birthdaymoney.persistence.entity;

// Generated 28.04.2013 16:40:29 by Hibernate Tools 3.4.0.CR1

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

/**
 * BmUser generated by hbm2java
 */
@Entity
@Table(name = "BM_User")
public class User implements java.io.Serializable {

    private int personId;
    private Role role;
    private Person person;
    private String hashPass;
    private String salt;

    public User() {
    }

    public User(Role role, Person person, String hashPass, String salt) {
        this.role = role;
        this.person = person;
        this.hashPass = hashPass;
        this.salt = salt;
    }

    @Id
    @GenericGenerator(name = "generator", strategy = "foreign", parameters = @Parameter(name = "property", value = "person")) 
    @GeneratedValue(generator = "generator")
    @Column(name = "PersonID", unique = true, nullable = false)
    public int getPersonId() {
        return this.personId;
    }

    public void setPersonId(int personId) {
        this.personId = personId;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "RoleID", nullable = false)
    public Role getRole() {
        return this.role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    @OneToOne(fetch = FetchType.LAZY, mappedBy="user", optional=false)
    @PrimaryKeyJoinColumn
    public Person getPerson() {
        return this.person;
    }

    public void setPerson(Person person) {
        this.person = person;
    }

    @Column(name = "HashPass", nullable = false, length = 100)
    public String getHashPass() {
        return this.hashPass;
    }

    public void setHashPass(String hashPass) {
        this.hashPass = hashPass;
    }

    @Column(name = "Salt", nullable = false, length = 50)
    public String getSalt() {
        return this.salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    public User(int personId, String username, String hashPass, String salt) {
        this.personId = personId;
        this.hashPass = hashPass;
        this.salt = salt;
    }
}
